package com.fishery.authority.service;

import com.fishery.authority.entity.Function;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fishery.authority.entity.FunctionParent;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author 711
 * @since 2021-01-13
 */
public interface FunctionService extends IService<Function> {

    /**
     * 查询所有权限
     *
     * @return
     */
    List<Function> queryAllFunction();

    /**
     * 权限分级
     *
     * @param functionList
     * @return
     */
    public List<FunctionParent> grand(List<Function> functionList);

    /**
     * 通过调用functionRoleService中的方法查找functionId并打入list
     *
     * @param roleId
     * @return
     */
    List<Function> findThroughRoleIdFromFunctionRole(String roleId);

    /**
     * 通过id查找function
     *
     * @param functionId
     * @return
     */
    Function findById(String functionId);

    /**
     *
     * @param roleId
     * @param functionId
     */
    void saveRoleFunction(String roleId, String[] functionId);

    /**
     * 通过baseId和baseIdentity查找权限
     *
     * @param baseId
     * @param baseIdentity
     * @return
     */
    List<Function> findByBase(String baseId, Integer baseIdentity);

    /**
     * 基地老板更新基地角色的权限
     *
     * @param baseId
     * @param baseIdentity
     * @param functionIdList
     */
    void UpdateBaseFunOfRole(String baseId, Integer baseIdentity, Map functionIdList);

    /**
     * 查找未对该角色授权的权限
     *
     * @param roleId
     * @return
     */
    List<Function> findOthersByRoleId(String roleId);

    void updateFunctionOfRole(String roleId, Map functionIdList);

    List<Function> findByRoleId(String roleId);

    List<Function> findByUserId(String userId);
}
